package com.mytx.sso.config;


import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里大于短信相关配置
 */
@Configuration
public class AliYunConfig {

    private String REGION_ID = "default";

    /**
     * 获取短信密钥id
     */
    @Value("${aliyun.accessKeyId}")
    private String ACCESS_KEY_ID;

    /**
     * 获取短信密钥
     */
    @Value("${aliyun.accessKeySecret}")
    private String ACCESS_SECRET;

    /**
     * 阿里大于网关
     */
    @Value("${aliyun.domain}")
    public String domain;

    /**
     * 签名名称
     */
    @Value("${aliyun.signature}")
    public String SIGNATURE;

    /**
     * api的名称
     */
    @Value("${aliyun.sendSmsAction}")
    public String SEND_SMS_ACTION;

    /**
     * api的名称
     */
    @Value("${aliyun.sendBatchSmsAction}")
    public String SEND_BATCH_SMS_ACTION;

    /**
     * 模板名称
     */
    @Value("${aliyun.templateCode}")
    public String TEMPLATE_CODE;

    /**
     * API版本号
     */
    public String VERSION = "2017-05-25";

    /**
     * 签名方式
     */
    public String SIGNATURE_METHOD = "HMAC-SHA1";

    /**
     * 签名算法版本
     */
    public String SignatureVersion = "1.0";



    /**
     * 获取发送短信的客户端
     * @return
     */
    @Bean
    public IAcsClient getIAcsCient(){
        DefaultProfile profile = DefaultProfile.getProfile(REGION_ID, ACCESS_KEY_ID, ACCESS_SECRET);
        IAcsClient client = new DefaultAcsClient(profile);
        return client;
    }


}
